/**
 * 
 */
package org.sheep.world.tile;

import org.sheep.R;
import org.sheep.sprite.Sprite;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;


/**
 * @author Gabriel Grill
 *
 */
public abstract class Tile {
  private final int xOffset = 0;
  private final int yOffset = 0;
  private Bitmap image;
   
  public Bitmap getImage() {
    return image;
  }
   
  public int getXOffset() {
    return xOffset;
  }
    
  public int getYOffset() {
    return yOffset;
  }

	public abstract int getResourceId();
  public void enter(Sprite s){}
	public void leave(Sprite s){}

  public void setSize(int width, int height, int viewWidth, int viewHeight, Context context) {
    
    Log.i("Tile", "Sizes: viewWidth: " + viewWidth + ", viewHeight: " + viewHeight +
          ", width: " + width + ", height: " + height);
    int xTileSize = (int)((double)viewWidth/(double)width) - xOffset;
    int yTileSize = (int)((double)viewHeight/(double)height) - yOffset;
    
    Log.i("Tile", "w: " + xTileSize + ", h: " + yTileSize);
    
    Resources res = context.getResources();
    image = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(res,
            getResourceId()), xTileSize, yTileSize, true); 
  };
}